import sys

import pygame


class State:
    def __init__(self, sub_menu, control_mode="horizontal"):
        self.sub_menu = sub_menu
        self.index = 0
        self.menu = self.sub_menu[self.index]
        self.control = getattr(self, f"{control_mode}_control")

    def horizontal_control(self, event):
        if event.type == pygame.KEYDOWN:
            if event.key == 100:
                self.index += 1
                if self.index > len(self.sub_menu) - 1:
                    self.index = len(self.sub_menu) - 1
            if event.key == 97:
                self.index -= 1
                if self.index < 0:
                    self.index = 0
            self.menu = self.sub_menu[self.index]
            print(self.menu)


menu_status = {
    "start": State(["t1", "t2", "t3"], "horizontal")
}

menu_state = menu_status['start']

pygame.init()
screen = pygame.display.set_mode((600, 600))
group = pygame.sprite.Group()
sp = pygame.sprite.Sprite()
sp.image = pygame.Surface((10, 10))
sp.image.fill((255, 0, 0))
sp.rect = sp.image.get_rect()

group.add(sp)
clock = pygame.time.Clock()

while True:
    screen.fill([0, 0, 0])
    clock.tick(60)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        menu_state.control(event)

    group.update()
    group.draw(screen)
    pygame.display.update()
